package com.iwunu.gateway.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.iwunu.gateway.entity.FaceLock;

import io.lettuce.core.dynamic.annotation.Param;

/**
 * @author kinfeng
 * @date 2021/3/18 10:00 AM
 * @desc
 */
public interface FaceLockRepository extends JpaRepository<FaceLock, Long> , JpaSpecificationExecutor<FaceLock> {
	
	   @Query(value="select i from FaceLock i where i.id=:lockId and i.isDel= false")
	   FaceLock selectFaceLockById(@Param("lockId") Long lockId);
	    
	    @Query(value="select i from FaceLock i where i.clientId=:clientId and i.isDel= false")
	    FaceLock selectFaceLockByMac(@Param("clientId") String clientId);
	    
	    @Query(value="update FaceLock i set i.isDel=true where  i.id=:lockId ")
	     int delByLockId(@Param("lockId") Integer lockId);
}
